package linear_list.leetcode.easy;

/**
 * @author bruin_du
 * @description 两个链表的第一个公共节点
 * @date 2022/5/26 20:22
 **/
public class Offer52_GetIntersectionNode {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        ListNode curA = headA,curB = headB;
        while(curA != curB){
            curA = curA == null ? headB : curA.next;
            curB = curB == null ? headA : curB.next;
        }
        return curA;
    }
}
